﻿//  --------------------------------
//  Copyright (c) AW Systems, Inc. All rights reserved.
//  This source code is made available under the terms of the Microsoft Public License (Ms-PL)
//  http://www.codeplex.com/SLAM/license
//  ---------------------------------

/*
	Finds all SharePoint SaveButton rendered button elements and replaces their click events
	with SLAM's SaveButton click event script
*/
function ModifySaveButtonClicks() {
	var inputs = document.getElementsByTagName('input');
	for (var i = 0; i < inputs.length; i++) {
		if (inputs[i].type && inputs[i].type.toLowerCase() === 'button' &&
			inputs[i].id && inputs[i].id.indexOf('diidIOSaveItem') >= 0 &&
			inputs[i].style.display !== 'none') {
			inputs[i].onclick = document.getElementById(document.getElementById('hdnSlamSaveButtonId').value).onclick;
		}
	}
}

ModifySaveButtonClicks();